#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from store.mdb_store import TableStore


# 机构募资事件列表
class SmtProjectStore(TableStore):
    def __init__(self, config):
        self.table = config.get('table', 'smt_manage_fund_info')
        self.table_config = {
            'mdb': config['mdb'],
            'table': self.table,
            'column_dic': {
                'qkid': "varchar(100) NOT NULL DEFAULT '' COMMENT 'qkid'",
                'fundId': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金id'",
                'fundEncodeId': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金编码id'",
                'fundNameCn': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金名字'",
                'fundType': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金类型'",
                'raiseStatus': "varchar(100) NOT NULL DEFAULT '' COMMENT '募集状态'",
                'raiseMoney': "varchar(100) NOT NULL DEFAULT '' COMMENT '募集资金'",
                'currency': "varchar(100) NOT NULL DEFAULT '' COMMENT '币种'",
                'raiseEnd': "varchar(100) NOT NULL DEFAULT '' COMMENT '募资完成时间'",
                'investCount': "varchar(100) NOT NULL DEFAULT '' COMMENT '投资案例'",
                'exitCount': "varchar(100) NOT NULL DEFAULT '' COMMENT '退出案例'",
                'avgTtMult': "varchar(100) NOT NULL DEFAULT '' COMMENT '回报倍数'",
                'avgIrr': "varchar(100) NOT NULL DEFAULT '' COMMENT '平均IRR'",
            },
            'uniq_idx_fields': ['id'],
            'idx_dic': {
                '{0}_name_idx'.format(self.table): ['fundNameCn']
            },
            'update_fields': [
                "qkid", "fundId", "fundEncodeId", 'fundNameCn', 'fundType', 'raiseStatus', 'raiseMoney', 'currency', 'raiseEnd', "investCount",
                "exitCount", "avgTtMult", "avgIrr"
            ]
        }
        super(SmtProjectStore, self).__init__(self.table_config)


# 机构募资事件详情
class SmtProjectDetailStore(TableStore):
    def __init__(self, config):
        self.table = config.get('table', 'smt_manage_fund_survey_info')
        self.table_config = {
            'mdb': config['mdb'],
            'table': self.table,
            'column_dic': {
                'qkid': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金id'",
                'namecn': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金名字'",
                'snamecn': "varchar(100) NOT NULL DEFAULT '' COMMENT '基金简称'",
                'establish': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'headName': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'headTwoName': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'indName': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'entStatus': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'companyStatus': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'fundRaiseStatus': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'frName': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'tags': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'industryTags': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'etlTags': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'etlTagIds': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'descCn': "varchar(800) NOT NULL DEFAULT '' COMMENT ''",
                'logo': "text NOT NULL COMMENT ''",
                'hasBaseInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasRegInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasRaiseInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasLawInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasFundInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasAnalyseInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasProductInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasListInfo': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasVcpe': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'orgId': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasLp': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'lpId': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasPartner': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasChange': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasEntInvest': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasBranch': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'hasEpRelation': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'similar': "text NOT NULL COMMENT ''",
                'shareDetailUrl': "text NOT NULL COMMENT ''",
                'vTel': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'vEmail': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'vContact': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'vAddress': "varchar(255) NOT NULL DEFAULT '' COMMENT ''",
                'webSite': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
                'epSlogan': "varchar(100) NOT NULL DEFAULT '' COMMENT ''",
            },
            'uniq_idx_fields': ['id'],
            'idx_dic': {
                '{0}_name_idx'.format(self.table): ['qkid']
            },
            'update_fields': [
                "namecn", "snamecn", "establish", 'headName', 'headTwoName', 'indName', 'entStatus', 'companyStatus',
                'fundRaiseStatus', "frName", "tags", "industryTags", "etlTags", "etlTagIds", "descCn", "logo",
                "hasBaseInfo", "hasRegInfo", "hasRaiseInfo", "hasLawInfo", "hasFundInfo", "hasAnalyseInfo",
                "hasProductInfo", "hasListInfo", "hasVcpe", "orgId", "hasLp", "lpId", "hasPartner", "hasChange",
                "hasEntInvest", "hasBranch", "hasEpRelation", "similar", "shareDetailUrl", "vTel", "vEmail",
                "vContact", "vAddress", "webSite", "epSlogan"
            ],
            'text_fields': [
                "logo", "similar", "shareDetailUrl"
            ],
            'dump_fields': [
                'tags', 'industryTags', 'etlTags', 'etlTagIds', 'similar'
            ]
        }
        super(SmtProjectDetailStore, self).__init__(self.table_config)


# 机构募资事件详情base
class SmtInfoBaseProjectDetailStore(TableStore):
    def __init__(self, config):
        self.table = config.get('table', 'smt_manage_fund_survey_base')
        self.table_config = {
            'mdb': config['mdb'],
            'table': self.table,
            'column_dic': {
                'qkid': "varchar(200) NOT NULL DEFAULT '' COMMENT '基金id'",
                'namecn': "varchar(200) NOT NULL DEFAULT '' COMMENT '基金名字'",
                'snamecn': "varchar(200) NOT NULL DEFAULT '' COMMENT '基金简称'",
                'establish': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'industry': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'eptype': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'capitaltype': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'regPlace': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'headPlace': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lptype': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lpCapital': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lpCurrency': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lpRaiseInfo': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'spType': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'spBusinessType': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'spCaseInfo': "varchar(500) NOT NULL DEFAULT '' COMMENT ''",
                'hnamecn': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'isnationnal': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'introductionCn': "varchar(1000) NOT NULL DEFAULT '' COMMENT ''",
                'vcpeType': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'vcpeForm': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'parentNameCn': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'isSecuritiesBlocker': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'vcpeCapital': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'vcpeCurrency': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundCountNum': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'investCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'exitCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'ipoExitCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'teamCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'rankCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'investPersonCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'intendArea': "text NOT NULL COMMENT '' COMMENT ''",
                'intendIndustry': "text NOT NULL COMMENT ''",
                'intendStage': "text NOT NULL COMMENT ''",
                'standardCn': "varchar(500) NOT NULL DEFAULT '' COMMENT ''",
                'fundType': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageId': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageOrgId': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageName': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageCap': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageCur': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'manageFundCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'raiseStatus': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundInvestCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundExitCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundGoalCurrency': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundGoalSize': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'raiseBegin': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundRaiseMoney': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundForm': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'isAmac': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'hasGovFund': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'applyId': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundLevel': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundClass': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'fundDeadline': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'financeSize': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'financeSizeCurrency': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'declareDeadline': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'gpSize': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'gpSizeCurrency': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'policyId': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'policyName': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'policyUrl': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lpInvestMoneyRmb': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'lpInvestFundCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'ipoInfo': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'openValue': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'totalMarketValue': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'epProfitCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
                'epBulletinCount': "varchar(200) NOT NULL DEFAULT '' COMMENT ''",
            },
            'uniq_idx_fields': ['qkid'],
            'idx_dic': {
                '{0}_name_idx'.format(self.table): ['namecn', 'snamecn']
            },
            'update_fields': [
                "namecn", "snamecn", "establish", "industry", "eptype", "capitaltype", "regPlace", "headPlace",
                "lptype", "lpCapital", "lpCurrency", "lpRaiseInfo", "spType", "spBusinessType", "spCaseInfo", "hnamecn",
                "isnationnal", "introductionCn", "vcpeType", "vcpeForm", "parentNameCn", "isSecuritiesBlocker",
                "vcpeCapital", "vcpeCurrency", "fundCount", "fundCountNum", "investCount", "exitCount", "ipoExitCount",
                "teamCount", "rankCount", "investPersonCount", "intendArea", "intendIndustry", "intendStage",
                "standardCn", "fundType", "manageId", "manageOrgId", "manageName", "manageCap", "manageCur",
                "manageFundCount", "raiseStatus", "fundInvestCount", "fundExitCount", "fundGoalCurrency",
                "fundGoalSize", "raiseBegin", "fundRaiseMoney", "fundForm", "isAmac", "hasGovFund", "applyId",
                "fundLevel", "fundClass", "fundDeadline", "financeSize", "financeSizeCurrency", "declareDeadline",
                "gpSize", "gpSizeCurrency", "policyId", "policyName", "policyUrl", "lpInvestMoneyRmb",
                "lpInvestFundCount", "ipoInfo", "openValue", "totalMarketValue", "epProfitCount", "epBulletinCount"
            ],
            'text_fields': [
                "intendArea", "intendIndustry", "intendStage"
            ],
            'dump_fields': [
                'intendArea', 'intendIndustry', 'intendStage'
            ]
        }
        super(SmtInfoBaseProjectDetailStore, self).__init__(self.table_config)
